Skip to content

[UI] Default locale#11412

Merged
SchrodingersGat merged 9 commits intoinventree:masterfrom
SchrodingersGat:default-locale
Feb 24, 2026
Merged

[UI] Default locale#11412
SchrodingersGat merged 9 commits intoinventree:masterfrom
SchrodingersGat:default-locale

Conversation

@SchrodingersGat
Copy link
Member

As part of the investigation for #11408 I discovered that the server default locale is not honored in the user interface.

This PR adds the following:

  • Ensure that the UI language initially defaults to the server "default locale" setting
  • Add a user profile option to select "default language"

@netlify
Copy link

netlify bot commented Feb 23, 2026

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit e9a3563
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/699d146fbc897e0008ea9822
😎 Deploy Preview https://deploy-preview-11412--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (🟢 up 1 from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed translation User Interface Related to the frontend / User Interface labels Feb 23, 2026
@SchrodingersGat SchrodingersGat added this to the 1.3.0 milestone Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure the frontend language defaults to the server’s configured default_locale when the user has not explicitly chosen a language, and adds a “Default Language” option in the user profile language selector.

Changes:

  • Allow language to be null in local state to represent “use default language”.
  • Add locale-priority logic and more defensive locale activation/loading.
  • Add “Default Language” option to the language dropdown and document language support.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/frontend/src/states/LocalState.tsx Changes language state to string | null with null as the default.
src/frontend/src/contexts/ThemeContext.tsx Wraps Mantine theme creation in a try/catch and falls back to default theme on errors.
src/frontend/src/contexts/LanguageContext.tsx Introduces locale prioritization and updates locale activation logic.
src/frontend/src/components/items/LanguageSelect.tsx Adds a “Default Language” option to the language selector UI.
docs/docs/concepts/user_interface.md Adds language support documentation section.
Comments suppressed due to low confidence (1)

src/frontend/src/contexts/LanguageContext.tsx:106

  • This effect computes lang as language || defaultLocale and only re-runs when language changes. As a result, when server info loads later, the server default_locale is not used as the initial UI locale (and the Accept-Language header logic below will not re-run to include the server locale). Compute lang using the documented priority (user language -> server.default_locale -> defaultLocale) and include server.default_locale in the dependency list so changes are honored.
    let lang: string = language || defaultLocale;

    // Ensure that the selected language is supported
    if (!Object.keys(getSupportedLanguages()).includes(lang)) {
      lang = defaultLocale;
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 38 to 50
return (
<Select
w={width}
data={langOptions}
data={[
{
value: '',
label: t`Default Language`
},
...langOptions
]}
value={value}
defaultValue={''}
onChange={setValue}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The select is controlled via value={value}, but when the stored locale is null you call setValue(locale) which leaves the control with null (no option selected). That means the new "Default Language" option (value '') is never shown as selected, and defaultValue has no effect in controlled mode. Consider controlling the select with value={locale ?? ''} and converting '' -> null in onChange so the UI reflects the default-language state.

Copilot uses AI. Check for mistakes.
}

if (locale != activeLocale) {
console.info('Changing locale from', activeLocale, 'to', locale);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a new console.info log on every locale change. There are no other console.info calls in the frontend, so this will create noisy production logs. Consider removing it or gating it behind a debug flag.

Suggested change
console.info('Changing locale from', activeLocale, 'to', locale);

Copilot uses AI. Check for mistakes.
Copy link
Member

@matmair matmair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SchrodingersGat SchrodingersGat merged commit 8a4ad4f into inventree:master Feb 24, 2026
42 of 43 checks passed
@SchrodingersGat SchrodingersGat deleted the default-locale branch February 24, 2026 05:08
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.99%. Comparing base (edc639d) to head (e9a3563).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11412      +/-   ##
==========================================
- Coverage   87.99%   87.99%   -0.01%     
==========================================
  Files        1295     1295              
  Lines       58806    58801       -5     
  Branches     1939     1939              
==========================================
- Hits        51745    51740       -5     
  Misses       6579     6579              
  Partials      482      482              
Components Coverage Δ
Backend Apps 91.69% <ø> (ø)
Backend General 93.37% <ø> (ø)
Frontend 70.83% <ø> (-0.02%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jmerro-c3d pushed a commit to jmerro-c3d/InvenTree that referenced this pull request Feb 25, 2026
* [UI] Support default server language

* Handle faulty theme

* Add option for default language

* Improve language selection

* Brief docs entry

* Fix typo

* Fix yarn build

* Remove debug msg

* Fix calendar locale
SchrodingersGat added a commit that referenced this pull request Feb 27, 2026
* add "updated_at" field to PurchaseOrder model

* change to use abstract po instead

* add api filters

* add show, order and filter by po updated_at date to frontend

* add tests and increment api_version

* change updated_at to null by default

* never trust github conflict resolution

* bump docker image to python 3.14 (#11414)

* chore(deps): bump the dependencies group across 1 directory with 4 updates (#11416)

Bumps the dependencies group with 4 updates in the / directory: [depot/setup-action](https://github.com/depot/setup-action), [depot/build-push-action](https://github.com/depot/build-push-action), [anchore/sbom-action](https://github.com/anchore/sbom-action) and [actions/stale](https://github.com/actions/stale).


Updates `depot/setup-action` from 1.6.0 to 1.7.1
- [Release notes](https://github.com/depot/setup-action/releases)
- [Commits](depot/setup-action@b0b1ea4...15c09a5)

Updates `depot/build-push-action` from 1.16.2 to 1.17.0
- [Release notes](https://github.com/depot/build-push-action/releases)
- [Commits](depot/build-push-action@9785b13...5f3b3c2)

Updates `anchore/sbom-action` from 0.21.1 to 0.22.2
- [Release notes](https://github.com/anchore/sbom-action/releases)
- [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md)
- [Commits](anchore/sbom-action@0b82b0b...28d7154)

Updates `actions/stale` from 10.1.1 to 10.2.0
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](actions/stale@9971854...b5d41d4)

---
updated-dependencies:
- dependency-name: depot/setup-action
  dependency-version: 1.7.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: depot/build-push-action
  dependency-version: 1.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: anchore/sbom-action
  dependency-version: 0.22.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: actions/stale
  dependency-version: 10.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [UI] Copy cells expansion (#11410)

* Prevent copy button if copy value is null

* Add "link" columns to order tables

* Support copy for default column types

* Tweak padding to avoid flickering issues

* Refactor IPNColumn

* Adjust visual styling

* Copy for SKU and MPN columns

* Add more copy columns

* More tweaks

* Tweak playwright testing

* Further cleanup

* More copy cols

* Fix auto pricing overwriting manual purchase price #10846 (#11411)

* Fix auto pricing overwriting manual purchase price #10846

* Added entry to api_version.py

---------

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>

* [UI] Default locale (#11412)

* [UI] Support default server language

* Handle faulty theme

* Add option for default language

* Improve language selection

* Brief docs entry

* Fix typo

* Fix yarn build

* Remove debug msg

* Fix calendar locale

* feat(backend): ensure restore of backups only works in correct enviroments (#11372)

* [FR] ensure restore of backups only works in correct enviroments
Fixes #11214

* update PR nbr

* fix wrong ty detection

* fix link

* ensure tracing does not enagage while running backup ops

* fix import

* remove debugging string

* add error codes

* add tests for backup and restore

* complete test for restore

* we do not need e2e on every matrix entry
there is no realy db dep here

* fix changelog format

* add flag to allow bypass

* update CHANGELOG.md

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
Co-authored-by: Matthias Mair <code@mjmair.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JustusRijke <53965859+JustusRijke@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Identifies a bug which needs to be addressed translation User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants